package com.zjdiepu.www.rest.api.zx;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.zjdiepu.www.base.BaseController;
import com.zjdiepu.www.base.annotation.Add;
import com.zjdiepu.www.base.core.ApiResponse;
import com.zjdiepu.www.common.consts.SystemConsts;
import com.zjdiepu.www.commpent.handler.TokenUserHelper;
import com.zjdiepu.www.ibiz.zpp.YwShenQingZxService;
import com.zjdiepu.www.model.base.dto.SysUser;
import com.zjdiepu.www.model.zx.request.ZxRestRequest;

/**
 * 业务信息Controller层<br/>
 * @author xiongxiaotun<br/>
 * @time 2017年04月24日 14时43分<br/>
 * @since 1.0<br/>
 */
@RestController
@RequestMapping(value= "ZxRestController", produces="application/json;charset=UTF-8", method = RequestMethod.POST)
@Api(tags = {"征信查询申请"}, produces="application/json;charset=UTF-8")
public class ZxRestController extends BaseController {
	@Resource
    private TokenUserHelper tokenUserHelper;
	@Resource
	private YwShenQingZxService ywShenQingZxService;
	
	/**
     * @author xiongxiaotun <br/>
     * @Title: saveApply  <br/>
     * @Description: 新增征信查询申请 <br/>
     * @param zxRestRequest
     * @return
     * @version V1.0  <br/>
     */
    @ApiOperation(value = "征信查询申请保存", response = Boolean.class, httpMethod="POST")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = SystemConsts.MOBILE_FLAG, defaultValue="ios", value = "请求机器标识", required = true, paramType = "header", dataType = "String"),
    	@ApiImplicitParam(name = SystemConsts.HEADER_FOR_TOKEN, defaultValue="Ajesget8XF7zNMpt+MM8cr0wI8S+IO6a9giEKNouXWvOO3wWWyaKjSDTqRUtHlcNbjCg1JaPdjRX6dX/O1oGLgE=", value = "token", required = true, paramType = "header", dataType = "String")
    })
    @RequestMapping(value = "saveApply")
    public ApiResponse saveApply(@Validated(Add.class) @RequestBody ZxRestRequest zxRestRequest) {
    	SysUser currentUser = tokenUserHelper.getUser();
    	ywShenQingZxService.saveApply(zxRestRequest, currentUser, true);
    	//开始生成征信文档
    	ywShenQingZxService.diepuCreatedWord(currentUser,zxRestRequest);
        return ApiResponse.success(true);
    }
}





